package kr.ne.jay.SimpleString;

import android.app.Activity;
import android.content.Context;
import android.hardware.SensorListener;
import android.hardware.SensorManager;
import android.os.Bundle;

public class StringShow extends Activity implements SensorListener {
	private StringView stringView;
	private SensorManager mgr;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		stringView = new StringView(this);
		setContentView(stringView);
		stringView.requestFocus();
		mgr = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
	}
	
	@Override
	protected void onResume() {
		super.onResume();
		mgr.registerListener(this, SensorManager.SENSOR_ACCELEROMETER);
	}
	
	@Override
	protected void onPause() {
		super.onPause();
		mgr.unregisterListener(this);
	}

	@Override
	public void onAccuracyChanged(int sensor, int accuracy) {
	}

	@Override
	public void onSensorChanged(int sensor, float[] values) {
		if (sensor == SensorManager.SENSOR_ACCELEROMETER) {
			stringView.addAcceleration(values);
		}
	}
}
